﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using wepoam;
using Armer;

namespace LR5
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        //создание класса оружие
        static Armament am = new Armament();

        private void ButtonAdd_Click(object sender, EventArgs e)
        {
            //поле для подсчета количества предметов
            int count;
            string s;

            if (RadioButtonKnife.Checked == true)
            {
                try
                {
                    count = int.Parse(TextBoxCount.Text);
                    var knife = new Knife();
                    knife.SetCost(100);
                    am.IncreaseCountKnives(count);
                    for (int i = 0; i < count; i++) am.Arms.Add(knife);
                    TextBoxCount.Clear();
                    s = "Добавлено ножей: " + Convert.ToString(count) + Environment.NewLine;
                    TextBoxArmament.Text += s;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Введите корректное значение!");
                    TextBoxCount.Clear();
                }
            }
            else if (RadioButtonKatana.Checked == true)
            {
                try
                {
                    count = int.Parse(TextBoxCount.Text);
                    var kat = new Katana();
                    kat.SetCost(500);
                    am.IncreaseCountKatanas(count);
                    for (int i = 0; i < count; i++) am.Arms.Add(kat);
                    s = "Добавлено катан: " + Convert.ToString(count) + Environment.NewLine;
                    TextBoxArmament.Text += s;
                    TextBoxCount.Clear();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Введите корректное значение!");
                    TextBoxCount.Clear();
                }
            }
            else if (RadioButtonPistol.Checked == true)
            {
                try
                {
                    count = int.Parse(TextBoxCount.Text);
                    var pist = new Pistol();
                    pist.SetCost(750);
                    am.IncreaseCountPistols(count);
                    for (int i = 0; i < count; i++) am.Arms.Add(pist);
                    s = "Добавлено пистолетов: " + Convert.ToString(count) + Environment.NewLine;
                    TextBoxArmament.Text += s;
                    TextBoxCount.Clear();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Введите корректное значение!");
                    TextBoxCount.Clear();
                }
            }
            else
            {
                try
                {
                    count = int.Parse(TextBoxCount.Text);
                    var shg = new Shotgun();
                    shg.SetCost(2000);
                    am.IncreaseCountShotguns(count);
                    for (int i = 0; i < count; i++) am.Arms.Add(shg);
                    s = "Добавлено дробовиков: " + Convert.ToString(count) + Environment.NewLine;
                    TextBoxArmament.Text += s;
                    TextBoxCount.Clear();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Введите корректное значение!");
                    TextBoxCount.Clear();
                }
            }
        }

        private void ButtonArm_Click(object sender, EventArgs e)
        {
            am.Arm();
            var calc = new Calculator();
            int fullCost;
            string s;

            fullCost = calc.Calculate(am);
            s = Environment.NewLine + "Общая стоимость: " + Convert.ToString(fullCost) + Environment.NewLine;
            s += "Всего ножей: " + Convert.ToString(am.GetCountKnives()) + Environment.NewLine;
            s += "Всего катан: " + Convert.ToString(am.GetCountKatanas()) + Environment.NewLine;
            s += "Всего пистолетов: " + Convert.ToString(am.GetCountPistols()) + Environment.NewLine;
            s += "Всего дробовиков: " + Convert.ToString(am.GetCountShotguns()) + Environment.NewLine;
            TextBoxArmament.Text += s;
        }

        private void ButtonExit_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
